﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

namespace SBarth.TheLionsShare
{
    public partial class Site : System.Web.UI.MasterPage
    {
        public enum WebPage : int { Home = 1, AboutUs = 2, Blog = 3, ContactUs = 4 };


        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Cache.SetCacheability(HttpCacheability.Public);
            Response.Cache.SetMaxAge(TimeSpan.FromDays(1));
        }


        public void ShowActivePage(WebPage currentPage)
        {
            String[] navbuttons = new String[] { "lstNavHome", "lstNavAbout", "lstNavBlog", "lstNavContact" };
            String currentPageControl = "";

            switch (currentPage)
            {
                case WebPage.Home:
                    currentPageControl = "lstNavHome";
                    break;
                case WebPage.AboutUs:
                    currentPageControl = "lstNavAbout";
                    break;
                case WebPage.Blog:
                    currentPageControl = "lstNavBlog";
                    break;
                case WebPage.ContactUs:
                    currentPageControl = "lstNavContact";
                    break;
                default:
                    currentPageControl = "";
                    break;
            }

            foreach (string s in navbuttons)
            {
                HtmlGenericControl ctl = (HtmlGenericControl)this.FindControl(s);
                if (ctl != null)
                {
                    if (s == currentPageControl)
                    {
                        ctl.Attributes["class"] = "navActive";
                    }
                    else
                    {
                        ctl.Attributes.Remove("class");
                    }
                }

                ctl = null;
            }

        }
    }
}